<template>
	<view>
		<view class="header flex">
			<view :class="[currentTab==index? 'othercss' : '']" :data-current="index" @tap="swichNav" v-for="(item,index) in listTitle"
			 :key="index">{{item.title}}</view>
		</view>
		<textarea class="main" :style="{height:height}" :value="test" @input="getValue">
		</textarea>
		<button class="buttoncss" @tap="save">确认</button>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				height: "",
				list: [],
				currentTab: -1,
				test: "",
				type: "", // 题目类型，单选1、多选2
				listTitle: [{
					title: '满意度',
					show: false,
					test: "很不满意\n不满意\n一般\n满意\n很满意"
				}, {
					title: '认可度',
					show: false,
					test: "很不同意\n不同意\n一般\n同意\n很同意"
				}, {
					title: '合适度',
					show: false,
					test: "优秀\n良好\n一般\n较差\n非常差"
				}, {
					title: '频率',
					show: false,
					test: "经常\n有时\n很少\n从不"
				}, {
					title: '数字',
					show: false,
					test: "1\n2\n3\n4\n5"
				}, {
					title: '学历',
					show: false,
					test: "初中\n高中\n大学本科\n硕士研究生\n博士研究生"
				}, {
					title: '星期',
					show: false,
					test: "星期一\n星期二\n星期三\n星期四\n星期五\n星期六"
				}, {
					title: '月份',
					show: false,
					test: "一月份\n二月份\n三月份\n四月份\n五月份\n六月份\n七月份\n八月份\n九月份\n十月份\n十一月份\n十二月份"
				}],
				showcss: false,
			};
		},
		methods: {
			//点击tab切换
			swichNav: function(e) {
				var that = this
				if (this.currentTab === e.target.dataset.current) {
					this.listTitle[this.currentTab].show = true
					this.test = this.listTitle[this.currentTab].test
					return false;

				} else {
					this.currentTab = e.target.dataset.current
					this.listTitle[this.currentTab].show = false
					this.test = this.listTitle[this.currentTab].test
				}
			},
			getValue(e) {
				this.test = e.detail.value
			},
			save() {
				/* if (this.type == '1') {
					uni.navigateTo({
						url: "../editoneChoice/editoneChoice?da=" + this.test
					})
				} else */ 
				if (this.type == '1' || this.type == '2') {
					uni.navigateTo({
						url: "../editduoChoice/editduoChoice?da=" + this.test
					})
				} else if (this.type == '3') {
					uni.navigateTo({
						url: "../oneChoice/oneChoice?da=" + this.test
					})
				} else {
					uni.navigateTo({
						url: "../duoChoice/duoChoice?da=" + this.test
					})
				}
			}
		},
		onShareAppMessage(options) {
			let shareObj = {
				success: (res) => {
					if (res.errMsg == 'shareAppMessage:ok') {
						uni.showToast({
							title: '分享成功',
							icon: 'success',
							duration: 1500
						})
					}
				},
				fail: () => {
					if (res.errMsg == 'shareAppMessage:fail cancel') {
						uni.showToast({
							title: '取消分享',
							icon: 'none',
							duration: 2000
						})
					} else if (res.errMsg == 'shareAppMessage:fail') {
						// 转发失败，其中 detail message 为详细失败信息
					}
				},
				complete: () => {
					// 转发结束之后的回调（转发成不成功都会执行）
				}
			}
		},
		onLoad(options) {
			let that = this
			uni.getSystemInfo({
				success: function(res) {
					that.height = res.windowHeight * 0.6 + 'px'
				}
			});
			that.type = options.type
			if (that.type == 1) {
				uni.setNavigationBarTitle({
					title: '单选题'
				});
			} else if (that.type == 2) {
				uni.setNavigationBarTitle({
					title: '多选题'
				});
			}
		},
		onShow() {

		}
	}
</script>

<style lang="scss">
	page {
		background: #F0F0F0;
		font-family: PingFang SC;
		font-weight: 500;
	}

	.header {
		background: #fff;
		justify-content: space-around;
		flex-wrap: wrap;
		padding: 30rpx;

		view {
			width: 146rpx;
			height: 80rpx;
			line-height: 80rpx;
			text-align: center;
			background: #F0F0F0;
			border-radius: 40rpx;
			color: #999;
			font-size: 30rpx;
			margin: 20rpx 0;
		}

		.othercss {
			background: #209FFC;
			color: #fff;
		}
	}

	.main {
		width: 690rpx;
		height: 50%;
		margin: 20rpx auto;
		background: #fff;
		border-radius: 10rpx;
		padding: 30rpx 0 0 30rpx;
		box-sizing: border-box;
	}

	.buttoncss {
		width: 690rpx;
		height: 100rpx;
		line-height: 100rpx;
		text-align: center;
		border-radius: 50rpx;
		color: #fff;
		background: #1F9FFB;
	}
</style>
